#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
Created on 2011/03/23

@author: Rafael
'''


#create a html server
from KThread import *
import SimpleHTTPServer
import SocketServer

class Servidor(threading.Thread):
    
    def startServer(self):
        self.server = KThread(target=self.createThread)
        self.server.start()
        pass
    
    def createThread(self):
        PORT = 8000
        Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

        self.httpd = SocketServer.TCPServer(("", PORT), Handler)

        print "serving at port", PORT
        self.httpd.serve_forever()
        pass
    
    #stop the server, by killing the threat
    def stopServer(self):
        self.server.kill()
        print "stop server"
        pass
    
#    def stopped (self):
#        return self._stop.isSet()
#        pass
    
    pass
#Para terminar o Servidor
#httpd.shutdown()